/**
 * @Date 2023-02-09 17:14:09
 * @Remark
 */

// config
import { PAGE_DEFAULT } from "config/setting";
// state
import { makeAutoObservable, toJS } from "mobx";

export interface SearchValue {
  phoneNumber?: string;
}

class State {
  loading = false;
  list: IllegalDto[] = [];
  total = 0;
  page = PAGE_DEFAULT.BEGIN;
  size = PAGE_DEFAULT.SIZE;
  search: SearchValue = {};
  editModal: IllegalDto | boolean = false;
  editModalLoading = false;
  selectedRowKeys: string[] = [];

  constructor() {
    makeAutoObservable(this);
  }
  setSearch(val: SearchValue = {}) {
    this.search = val;
  }
  getSearch() {
    return toJS(this.search);
  }
  getList() {
    return toJS(this.list);
  }
  setPage(val = PAGE_DEFAULT.BEGIN) {
    this.page = val;
  }
  setSize(val = PAGE_DEFAULT.SIZE) {
    this.size = val;
  }
  get editModalShow() {
    return !!this.editModal;
  }
  get editInfo() {
    if (typeof this.editModal !== "boolean") {
      return toJS(this.editModal);
    }
    return null;
  }
}

export const state = new State();
